package cn.wolfcode.qo;

import cn.hutool.core.date.DateUtil;
import cn.wolfcode.meiju.BussinessReportEnum;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Getter
@Setter
public class BussinessReportObject extends QueryObject {

    //分组依据给个默认值，不然一开始进去就找不到分组依据
    private String groupType = BussinessReportEnum.CONSUME.getStatusName();
    private Integer businessId;
    //由于我们前端传来的都是字符串，如果没写，则默认为空字符串
    //所以必须贴个注解，通过注解解析为对应的时间字符格式，然后赋值给对象
    //解析不了则为null
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date minTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date maxTime;
    private Integer status;
    private Integer ano;

    public  Date getMaxTime(){
        if (maxTime == null){
            return null;
        }
        return DateUtil.endOfDay(maxTime);
    }
}
